cmake_minimum_required(VERSION 3.8)
project(image_resize_cpp)

# 编译器警告优化
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()

# 查找依赖
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(cv_bridge REQUIRED)
find_package(OpenCV REQUIRED)

# 添加可执行文件
add_executable(image_resize_node src/image_resize_node.cpp)

# 链接依赖
ament_target_dependencies(image_resize_node
  rclcpp
  sensor_msgs
  cv_bridge
)

# 链接 OpenCV
target_link_libraries(image_resize_node ${OpenCV_LIBS})
target_include_directories(image_resize_node PRIVATE ${OpenCV_INCLUDE_DIRS})

# 安装
install(TARGETS image_resize_node
  DESTINATION lib/${PROJECT_NAME}
)

# 自动代码检查（可选）
if(BUILD_TESTING)
  find_package(ament_lint_auto REQUIRED)
  set(ament_cmake_copyright_FOUND TRUE)
  set(ament_cmake_cpplint_FOUND TRUE)
  ament_lint_auto_find_test_dependencies()
endif()

ament_package()
